﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Client_Revenue
{
    public partial class AddCarrier : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void ckSameAddress_CheckedChanged(object sender, EventArgs e)
        {
            if (!chkSameAddress.Checked)
            { pnContactAddres.Visible = true; }
            else
            { pnContactAddres.Visible = false; }
        }

        protected void chkIsPrimary_CheckedChanged(object sender, EventArgs e)
        {

        }

        protected void btAddClient_Click(object sender, EventArgs e)
        {

        }

        protected void btnCancel_Click(object sender, EventArgs e)
        {
            ResetFormControlValues(this);
        }

        private void ResetFormControlValues(Control parent)
        {
            foreach (Control c in parent.Controls)
            {
                if (c.Controls.Count > 0)
                {
                    ResetFormControlValues(c);
                }
                else
                {
                    switch (c.GetType().ToString())
                    {
                        case "System.Web.UI.WebControls.TextBox":
                            ((TextBox)c).Text = "";
                            break;
                        case "System.Web.UI.WebControls.CheckBox":
                            if (((CheckBox)c).Checked == false)
                            { ((CheckBox)c).Checked = true; }
                            else
                            { ((CheckBox)c).Checked = false; }

                            break;
                        case "System.Web.UI.WebControls.RadioButton":
                            ((RadioButton)c).Checked = false;
                            break;

                    }
                }
            }
        }
    }
}